#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Function Category Module"""
__author__ = "Lei Chen <hide1713@gmail.com>"
import logging

class FunctionCategory(object):
    """Function Category to represent the following data
    INFORMATION STORAGE AND PROCESSING
     [J] Translation,  ribosomal structure and biogenesis
     [A] RNA processing and modification
     [K] Transcription
     [L] Replication,  recombination and repair
     [B] Chromatin structure and dynamics

     CELLULAR PROCESSES AND SIGNALING
     [D] Cell cycle control,  cell division,  chromosome partitioning
     [Y] Nuclear structure
     [V] Defense mechanisms
     [T] Signal transduction mechanisms
     [M] Cell wall/membrane/envelope biogenesis
     [N] Cell motility
     [Z] Cytoskeleton
     [W] Extracellular structures
     [U] Intracellular trafficking,  secretion,  and vesicular transport
     [O] Posttranslational modification,  protein turnover,  chaperones

     METABOLISM
     [C] Energy production and conversion
     [G] Carbohydrate transport and METABOLISM
     [E] Amino acid transport and METABOLISM
     [F] Nucleotide transport and METABOLISM
     [H] Coenzyme transport and METABOLISM
     [I] Lipid transport and METABOLISM
     [P] Inorganic ion transport and METABOLISM
     [Q] Secondary metabolites biosynthesis,  transport and catabolism

     POORLY CHARACTERIZED
     [R] General function prediction only
     [S] Function unknown               
    """
    
    def __init__(self,file_name):
        """
        Build function category with a cog_model object
        """
        cat = "JAKLBDYVTMNZWUOCGEFHIPQRS"
        self.func_cat = {}
        self.file_name = file_name
        for c in cat:
            self.func_cat[c] = 0
        self.log = logging.getLogger(self.__class__.__name__)


    def add_cog(self, cog):
        """
        Increase the read number of the category
        """
        for c in cog.category:
            try:
                self.func_cat[c] += cog.number_of_hits;
            except KeyError:
                self.log.info("Unknown category " + c)
                pass
        
        
        

